package com.jarvis.pzz.modules.releasedemand.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.jarvis.pzz.R;
import com.jarvis.pzz.models.LabelList1Model;
import com.jarvis.pzz.models.RequirementInfoModel;
import com.jarvis.pzz.util.ViewHolderUtil;

import java.util.List;

/**
 * Created by Administrator on 2017/9/16 0016.
 */

public class ReleaseFacilitiesAdapter extends BaseAdapter {
    private List<LabelList1Model> list;
    private Context context;

    public ReleaseFacilitiesAdapter(List<LabelList1Model> list, Context context) {
        this.context = context;
        this.list = list;
    }

    public void notifyDataSetChanged(List<LabelList1Model> list) {
        this.list = list;
        notifyDataSetChanged();
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        final LabelList1Model releseFacilitiesMode = list.get(position);
        convertView = LayoutInflater.from(context).inflate(R.layout.item_findshop, null);
        ImageView imageView = ViewHolderUtil.get(convertView, R.id.iv_img);

        if ("1".equals(releseFacilitiesMode.getFlag())) {
            Glide.with(context)
                    .load(releseFacilitiesMode.getLabImgAbledPath())
                    .centerCrop()
                    .error(R.drawable.img_banner)
                    .into(imageView);
        } else {
            Glide.with(context)
                    .load(releseFacilitiesMode.getLabImgDisabledPath())
                    .centerCrop()
                    .error(R.drawable.img_banner)
                    .into(imageView);
        }

        return convertView;
    }
}

